#pragma once
#include "d3dutil.h"
#include "LevelElement.h"
#include "Vertex.h"
#include <vector>

class CubePhysX;
class NxActor;
class PhysX;

using namespace std;
//-----------------------------------------------------
// Cube Class									
//-----------------------------------------------------
class Cube : public LevelElement
{
public:
	Cube(Level *pLevel, float width=1, float height=1, float depth=1, D3DXCOLOR color=D3DXCOLOR(1,1,1,1));				// Constructor
	virtual ~Cube();		// Destructor

	virtual void Initialize(ContentManager *pContentManager);
	virtual void Tick(const InputState & refInputState);
	virtual void Draw(const RenderContext* pRenderContext, ID3D10ShaderResourceView* shadowdepthmap = 0);
	void SetRigid(bool b){m_bRigid=b;} // if true static

	//overriding base members to allow PhysX
	virtual void Translate(const D3DXVECTOR3 pos);
	virtual void Rotate(const D3DXVECTOR3 angles);
	virtual void Scale(const D3DXVECTOR3 scales);

private: 
	void CreateEffect(ContentManager *pContentManager);
	void GetEffectVariables(ID3D10Effect* pEffect);
	void DefineInputlayout();
	void BuildShape();
	void AddTriangle (unsigned int a, unsigned int b, unsigned c);
	void BuildVertexBuffer();
	void BuildIndexBuffer();

	//-------------------------------------------------
	// Datamembers								
	//-------------------------------------------------
	ID3D10InputLayout*			m_pVertexLayout;
	ID3D10Buffer*				m_pVertexBuffer;
	ID3D10Buffer*				m_pIndexBuffer;

	ID3D10Effect*				m_pDefaultEffect;
	ID3D10EffectTechnique*		m_pDefaultTechnique;

	ID3D10EffectMatrixVariable* m_pWorldViewProjectionVariable;
	ID3D10EffectMatrixVariable* m_pWorldVariable;
	ID3D10EffectVectorVariable* m_pLightDirVariabele;

	vector<VertexPosNormCol> m_VecVertices;
	vector<DWORD> m_VecIndices;

	float m_Width,  m_Height,  m_Depth;
	D3DXVECTOR3 m_Pos;
	D3DXCOLOR m_Color;


	/**
	* The physics representation of an object
	*/
	NxActor *m_pActor;
	bool m_bRigid;
	CubePhysX* m_pPhysXMesh;
	// -------------------------
	// Disabling default copy constructor and default 
	// assignment operator.
	// -------------------------
	Cube(const Cube& yRef);									
	Cube& operator=(const Cube& yRef);	
};

 
